home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / MATH / NRPAS13 / RATINT.DEM < prev    next >
Text File  |  1991-04-29  |  746b  |  36 lines

  1. PROGRAM d3r2(input,output);
  2. (* driver for routine RATINT *)
  3. CONST
  4.    npt=6;
  5.    eps=1.0;
  6. TYPE
  7.    glnarray = ARRAY [1..npt] OF real;
  8. VAR
  9.    dyy,xx,yexp,yy : real;
  10.    i : integer;
  11.    x,y : glnarray;
  12.  
  13. FUNCTION f(x,eps: real): real;
  14. BEGIN
  15.    f := x*exp(-x)/(sqr(x-1.0)+eps*eps)
  16. END;
  17.  
  18. (*$I MODFILE.PAS *)
  19. (*$I RATINT.PAS *)
  20.  
  21. BEGIN
  22.    FOR i := 1 to npt DO BEGIN
  23.       x[i] := i*2.0/npt;
  24.       y[i] := f(x[i],eps)
  25.    END;
  26.    writeln('Diagonal rational function interpolation');
  27.    writeln;
  28.    writeln('x':5,'interp.':13,'accuracy':14,'actual':12);
  29.    FOR i := 1 to 10 DO BEGIN
  30.       xx := 0.2*i;
  31.       ratint(x,y,npt,xx,yy,dyy);
  32.       yexp := f(xx,eps);
  33.       writeln(xx:6:2,yy:12:6,' ':4,dyy:11,yexp:12:6)
  34.    END
  35. END.
  36.